package service;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import dao.BlackListDao;
import dao.ProvinceTop3Dao;
import dao.impl.BlackListDaoImpl;
import dao.impl.ProvinceTop3DaoImpl;
import domain.BlackList;
import domain.ProvinceTop3;

import java.util.List;

public class ProvinceTop3Service {
    String valueAsString = null;
    private ProvinceTop3Dao contacts = new ProvinceTop3DaoImpl();
    public String ToJson() {
        List<ProvinceTop3> list = contacts.SelectTop3ByProvince();
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            valueAsString = objectMapper.writeValueAsString(list);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
        return valueAsString;
    }
}
